package com.wlit.alarm;

import com.wlit.alarm.service.HttpServer;
import org.apache.log4j.Logger;
import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;

import javax.swing.*;
import java.awt.*;

public class Main {

    private static final Logger logger = Logger.getLogger(Main.class);

    /**
     * 默认端口6913
     */
    public static int HTTP_PORT = 6913;

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.osLookAndFeelDecorated;
                    org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
                    UIManager.put("RootPane.setupButtonVisible", false);
                }catch (Exception e){
                    e.printStackTrace();
                }
                try {
//                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//
//                    JFrame.setDefaultLookAndFeelDecorated(true);
                    MainFrame frame = new MainFrame();
                    frame.initGUI();
                    frame.setVisible(true);

                    new Thread(() -> {
                        try {
                            HttpServer server = new HttpServer(HTTP_PORT);
                            server.init(frame.getAlarmService());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }, "Http-Service").start();

                } catch (Exception e) {
                    e.printStackTrace();
                }


            }
        });
        logger.info("启动完成");
    }
}
